package yuzhou;

import java.io.*;
import java.util.Properties;

public class Config {
    public final static String ENTITYLIST = "EntityList";
    public final static String GlOWOBJ = "GlowObject";

    private static File file = new File("yuzhou.properties");
    static{
        if(!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static void writeConfig(String key,String value) throws IOException {
        Properties prop = new Properties();
        prop.load(new FileInputStream(file));
        /*Enumeration en = prop.propertyNames();
        while(en.hasMoreElements()) {
            String strKey = (String) en.nextElement();
            String strValue = prop.getProperty(strKey);
            prop.setProperty(strKey,strValue);
        }*/
        prop.setProperty(key,value);

        prop.store(new FileOutputStream(file),null);
    }

    public static String readConfig(String key) throws IOException {
        Properties prop = new Properties();
        prop.load(new FileInputStream(file));
        return prop.getProperty(key);
    }
}
